﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    public class Logger
    {
        public delegate void LoggerDelegate(String text);
        public LoggerDelegate logger = null;
        private static Logger instance = null;
        private Logger()
        {

        }
        public static Logger getInstance()
        {
            if (instance == null)
            {
                instance = new Logger();
            }
            return instance;
        }
        public void setDelegate(LoggerDelegate logger)
        {
            this.logger = logger;
        }
        public void logText(String text)
        {
            if (this.logger != null)
            {
                logger(text);
            }
        }
        public static void log(String text)
        {
            Logger.getInstance().logText(text);
        }
    }
}
